package com.only4play.authcenter.infrastructure.convert;


import com.only4play.authcenter.constants.ResourceType;

import javax.persistence.AttributeConverter;

/**
 * @author hinzzz www.hinzzz.cn 157957329@qq.com
 * 2024-03-04
 */


public class ResourceTypeConverter implements AttributeConverter<ResourceType,Integer> {

  @Override
  public Integer convertToDatabaseColumn(ResourceType resourceType) {
    return resourceType.getCode();
  }

  @Override
  public ResourceType convertToEntityAttribute(Integer code) {
    return ResourceType.of(code).orElse(null);
  }
}